import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import './plugins/element.js'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/global.css'

Vue.config.productionTip = false

Vue.prototype.$http=axios;

router.beforeEach((to,from,next)=>{
  if(to.meta.requireAuth){
    if(window.sessionStorage.getItem('token')){
      next();
    }else{
      next({
        path:'/login',
        query:{redirect:to.fullPath}
      });
    }
  }else{
    next();
  }
})


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
